home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 9,300 to 9,399 / 9300.zip / AOLDLs / HTML & Web Tools (MAC) / WEB_ Print2Pict 3.7.1 / Print2Pict 3.7.1Ä.sit / Print2Pict 3.7.1ƒ / Sourcesƒ / tools.c < prev    next >
Text File  |  2004-12-22  |  2KB  |  112 lines

  1. /*===================
  2.  
  3.     Utility routines.
  4.     
  5.     ⌐ B.Raoult 92
  6.  
  7. ====================*/
  8. #include "tools.h"
  9.  
  10. #ifndef __TEXTUTILS__
  11. #    include <TextUtils.h>
  12. #endif
  13.  
  14. /*
  15.     Returns the rectangle of a dialog item 
  16. */
  17.  
  18. Rect GetItemR(DialogPtr dialog, short itemno)
  19. {    
  20.     Rect     box;
  21.     short     type;
  22.     Handle    item;
  23.     
  24.     GetDItem(dialog,itemno,&type,&item,&box);
  25.     return box;
  26. }
  27.  
  28. /*
  29.     Returns the handle of a dialog item 
  30. */
  31.  
  32. Handle GetItemH(DialogPtr dialog, short itemno)
  33. {    
  34.     Rect     box;
  35.     short     type;
  36.     Handle    item;
  37.     
  38.     GetDItem(dialog,itemno,&type,&item,&box);
  39.     return item;
  40. }
  41.  
  42. /*
  43.     Sets a checkbox
  44. */
  45.  
  46. void SetCheck(DialogPtr dialog,short itemno,Boolean on_off)
  47. {
  48.     SetCtlValue((ControlHandle) GetItemH(dialog,itemno),on_off);
  49. }
  50.  
  51. /*
  52.     Get the value of a checkbox
  53. */
  54.  
  55. Boolean GetCheck(DialogPtr dialog, short itemno)
  56. {
  57.     return GetCtlValue((ControlHandle) GetItemH(dialog,itemno));
  58. }
  59.  
  60. /*
  61.     Toggle a checkbox, returns the new status
  62. */
  63.  
  64. Boolean ClickCheck(DialogPtr dialog, short itemno)
  65. {
  66.     ControlHandle item = (ControlHandle) GetItemH(dialog,itemno);
  67.     SetCtlValue(item,1-GetCtlValue(item));
  68.     return GetCtlValue(item);
  69. }
  70.  
  71. /*
  72.     Put a long integer into an edittext.
  73. */
  74.  
  75.  
  76. void Long2Dialog(DialogPtr dialog, short itemno, long value)
  77. {
  78.     Str255    buf;
  79.     
  80.     NumToString(value,buf);
  81.     SetIText(GetItemH(dialog,itemno),buf);
  82.  
  83. }
  84.  
  85. /*
  86.     Get a long integer from an edittext.
  87. */
  88.  
  89.  
  90. long Dialog2Long(DialogPtr dialog, short itemno)
  91. {
  92.     Str255    buf;
  93.     long    value;
  94.     
  95.     GetIText(GetItemH(dialog,itemno),buf);
  96.     StringToNum(buf,&value);
  97.     return value;
  98.  
  99. }
  100.  
  101. /*
  102.     Checks if color quickdraw is here. I know, I should use Gestalt...
  103. */
  104.  
  105.  
  106. Boolean HasColor(void)
  107. {
  108.     SysEnvRec s;
  109.     if(SysEnvirons(1,&s) == noErr) return s.hasColorQD;
  110.     return false;
  111. }
  112.